package com.chen106106.sstest.service;

import java.util.List;

import com.chen106106.sstest.dao.UserMgrDao;
import com.chen106106.sstest.model.User;

/**
 * 
 * @author chenz106106@gmail.com
 * 2012-7-16 下午11:27:20
 *
 */
public class UserMgrServiceImpl implements UserMgrService {

	private UserMgrDao userMgrDao;
	
	public void setUserMgrDao(UserMgrDao userMgrDao){
		this.userMgrDao = userMgrDao;
	}
	
	@Override
	public boolean todayIsLogin() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public User getUserInfoById(int id) {
		// TODO Auto-generated method stub
		User user = userMgrDao.queryById(id);
		return user;
	}

	@Override
	public boolean isRegister(String username) {
		// TODO Auto-generated method stub
		List<User> users = userMgrDao.queryList("username", username);
		if(null==users || users.size()<1){
			return true;
		}
		return false;
	}

	@Override
	public long userRegister(User user) {
		// TODO Auto-generated method stub
		return userMgrDao.add(user);
	}

	@Override
	public List<User> queryList(int...params ) {
		// TODO Auto-generated method stub
		
		return userMgrDao.queryList(params);
	}

	@Override
	public boolean updateUser(User user) {
		// TODO Auto-generated method stub
		return this.userMgrDao.update(user);
	}

	@Override
	public boolean deleteUser(int uid) {
		// TODO Auto-generated method stub
		return this.userMgrDao.delete(uid);
	}

	@Override
	public int getUserCount() {
		// TODO Auto-generated method stub
		return this.userMgrDao.countUserNum();
	}

}
